



import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.URL;
import java.net.URLConnection;
import java.util.Iterator;
import javax.xml.parsers.FactoryConfigurationError;
import javax.xml.stream.XMLStreamException;
import org.apache.axiom.om.OMAbstractFactory;
import org.apache.axiom.om.OMElement;
import org.apache.axiom.om.OMFactory;
import org.apache.axiom.om.OMNamespace;
import org.apache.axiom.om.impl.llom.util.AXIOMUtil;
import org.apache.axiom.soap.SOAPHeaderBlock;
import org.apache.axis2.Constants;
import org.apache.axis2.addressing.EndpointReference;
import org.apache.axis2.client.Options;
import org.apache.axis2.client.ServiceClient;
import org.apache.axis2.databinding.utils.BeanUtil;
import org.apache.axis2.engine.DefaultObjectSupplier;
import org.apache.axis2.util.Base64;
import org.apache.axis2.client.Options;
import org.apache.commons.httpclient.HttpClient;

public class AXIOMClient {
	public static void main(String[] args) throws IOException, XMLStreamException, FactoryConfigurationError {



		ServiceClient client = new ServiceClient();
		EndpointReference er = new EndpointReference("http://localhost:8080/axis2Example-1.0.0-SNAPSHOT/services/SystemService");
		Options opt = client.getOptions();
		opt.setTo(er);
		OMFactory fac = OMAbstractFactory.getSOAP12Factory();
		String username="dfadfa";
		String password="dfdfdfdf";
		URL url = new URL("http://localhost:8080/axis2Example-1.0.0-SNAPSHOT/j_spring_security_check");
		URLConnection uc = url.openConnection();
		String authorizationString = "Basic " + new sun.misc.BASE64Encoder().encode((username+":"+password).getBytes());
		uc.setRequestProperty ("Authorization", authorizationString);
uc.connect();			
				OMNamespace ns = fac.createOMNamespace("https://services.unisa.it", "loginUser");
				//use the factory to create three elements to represent the book element
				OMElement root = fac.createOMElement("a",ns);
				OMElement ssn = fac.createOMElement("ssn",ns);
				ssn.addChild(fac.createOMText("fdfdrrrrrr"));
				root.addChild(ssn);
				OMElement method = fac.createOMElement("loginUser", ns);
				method.addChild(root);
				System.out.println(method);
				OMElement result = client.sendReceive(method);

				

	}

}
